// Copyright (C) 2024 Kumo inc.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <string>
#include <vector>
#include <nlohmann/json.hpp>

namespace rigel {

struct IndexRequest {
    std::string index_name;
    int dimension;
    std::string index_type = "Approximate";
    std::string space_type = "IP";
    int ef_construction = 512;
    int M = 16;
};

struct AddDocumentsRequest {
    std::string index_name;
    std::vector<int> ids;
    std::vector<std::vector<float>> vectors;
};

struct DeleteDocumentsRequest {
    std::string index_name;
    std::vector<int> ids;
};

struct SearchRequest {
    std::string index_name;
    std::vector<float> query_vector;
    int k;
    int ef_search = 512;
};

// JSON Serialization
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IndexRequest, index_name, dimension, index_type, space_type, ef_construction, M)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(AddDocumentsRequest, index_name, ids, vectors)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DeleteDocumentsRequest, index_name, ids)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SearchRequest, index_name, query_vector, k, ef_search)

}  // namespace rigel
